package com.iflytek.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iflytek.bean.Admin;
import com.iflytek.bean.AdminExample;
import com.iflytek.mapper.AdminMapper;
import com.iflytek.service.AdminService;

@Service
public class AdminServiceImpl implements AdminService{

	@Autowired
	private AdminMapper adminMapper;
	
	
	@Override
	public List<Admin> selectByExample(Object object) {
		return adminMapper.selectByExample(null);
	}

	@Override
	public void insertSelective(Admin admin) {
		adminMapper.insertSelective(admin);
	}

	@Override
	public void deleteByPrimaryKey(Integer id) {
		adminMapper.deleteByPrimaryKey(id);
	}

	@Override
	public void updateByPrimaryKeySelective(Admin admin) {
		adminMapper.updateByPrimaryKeySelective(admin);
	}

	@Override
	public Admin findAdminByUsername(String username) {
		
		AdminExample example = new AdminExample();
		example.createCriteria().andUsernameEqualTo(username);
		List<Admin> list = adminMapper.selectByExample(example);
		
		return list.size() > 0 ? list.get(0) : null;
	}

}
